<?php

use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
use Fisharebest\Webtrees\Http\RequestHandlers\ExportGedcomClient;
use Fisharebest\Webtrees\Http\RequestHandlers\ExportGedcomServer;
use Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees;
use Fisharebest\Webtrees\I18N;

?>

<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ManageTrees::class, ['tree' => $tree->name()]) => I18N::translate('Manage family trees'), $title]]) ?>

<h1><?= $title ?></h1>

<div class="row">
    <div class="col-sm-4">
        <div class="card">
            <div class="card-header">
                <?= I18N::translate('A file on the server') ?>
            </div>
            <div class="card-body">
                <form method="post" action="<?= e(route(ExportGedcomServer::class, ['tree' => $tree->name()])) ?>" class="form form-horizontal">
                    <?= csrf_field() ?>

                    <button type="submit" class="btn btn-primary">
                        <?= view('icons/save') ?>
                        <?= /* I18N: A button label. */
                        I18N::translate('continue') ?>
                    </button>
                </form>
            </div>
        </div>
    </div>

    <div class="col-sm-8">
        <div class="card">
            <div class="card-header">
                <?= I18N::translate('A file on your computer') ?>
            </div>
            <div class="card-body">
                <form method="post" action="<?= e(route(ExportGedcomClient::class, ['tree' => $tree->name()])) ?>" class="form form-horizontal">
                    <?= csrf_field() ?>

                    <p class="card-title">
                        <?= I18N::translate('Export preferences') ?>
                    </p>

                    <div class="form-check">
                        <label class="form-check-label">
                            <input class="form-check-input" type="checkbox" name="zip">
                            <?= I18N::translate('Compress the GEDCOM file') ?>
                        </label>
                        <?= view('help/link', ['topic' => 'zip-gedcom']) ?>
                    </div>

                    <div class="form-check">
                        <label class="form-check-label">
                            <input class="form-check-input" type="checkbox" name="media">
                            <?= I18N::translate('Include media (automatically zips files)') ?>
                        </label>
                    </div>

                   <div class="form-check">
                        <label class="form-check-label">
                            <input class="form-check-input" type="checkbox" name="convert">
                            <?= I18N::translate('Convert from UTF-8 to ISO-8859-1') ?>
                        </label>
                       <?= view('help/link', ['topic' => 'iso-8859-1']) ?>
                    </div>

                    <?php if ($tree->getPreference('GEDCOM_MEDIA_PATH')) : ?>
                        <hr>

                        <label>
                            <input type="checkbox" name="media-path" value="<?= e($tree->getPreference('GEDCOM_MEDIA_PATH')) ?>">
                            <?= /* I18N: A media path (e.g. C:\aaa\bbb\ccc\) in a GEDCOM file */
                            I18N::translate('Add the GEDCOM media path to filenames') ?>
                        </label>
                        <p>
                            <?= /* I18N: %s is the name of a folder. */
                            I18N::translate('Media filenames will be prefixed by %s.', '<code dir="ltr">' . e($tree->getPreference('GEDCOM_MEDIA_PATH')) . '</code>') ?>
                        </p>
                    <?php endif ?>

                    <hr>

                    <p class="card-title">
                        <?= I18N::translate('Apply privacy settings') ?>
                    </p>

                    <fieldset class="form-group">
                        <div class="form-check form-check-inline">
                            <label>
                                <input type="radio" name="privatize_export" value="none" checked>
                                <?= I18N::translate('None') ?>
                            </label>
                        </div>
                        <div class="form-check form-check-inline">
                            <label>
                                <input type="radio" name="privatize_export" value="gedadmin">
                                <?= I18N::translate('Manager') ?>
                            </label>
                        </div>
                        <div class="form-check form-check-inline">
                            <label>
                                <input type="radio" name="privatize_export" value="user">
                                <?= I18N::translate('Member') ?>
                            </label>
                        </div>
                        <div class="form-check form-check-inline">
                            <label>
                                <input type="radio" name="privatize_export" value="visitor">
                                <?= I18N::translate('Visitor') ?>
                            </label>
                        </div>
                    </fieldset>

                    <button type="submit" class="btn btn-primary">
                        <?= view('icons/download') ?>
                        <?= /* I18N: A button label. */
                        I18N::translate('continue') ?>
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>

<?= view('modals/ajax') ?>
